#include<bits/stdc++.h>
using namespace std;
struct node{
	float d;
	float v;
	float a;
};
struct P{
	int pp;
	int vis;
};
int cnt,cnt1,T,n,m,L,V,l;
float d,x,v,a,dd;
node car[100004];
P p[100004];
int sreach(int l,int r,int x){
	int mid;
	while(l<r){
		mid=(l+r)/2;
		if(p[mid].pp>=x){
			r=mid;
		}
		else{
			l=mid+1;
		}
	}
	return l;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
	for(int i=1;i<=T;i++){
		scanf("%d%d%d%d",&n,&m,&L,&V);
		for(int j=1;j<=n;j++){
			scanf("%f%f%f",&car[j].d,&car[j].v,&car[j].a);
		}
		for(int j=1;j<=m;j++){
			scanf("%d",&p[j].pp);
			p[j].vis=0;
		}
		for(int j=1;j<=n;j++){
			if((car[j].a==0&&car[j].v>3)||(car[j].a>0&&car[j].v>=3)){
				l=sreach(1,m,car[j].d);
				if(d>=p[l].pp)continue;
				p[l].vis=1;
				cnt++;
				continue;
			}
			if(car[j].a==0&&car[j].v<=3)continue;
			if(car[j].a<0){
				if(car[j].v<=3){
					continue;
				}
			}
			v=car[j].v,d=car[j].d,a=car[j].a;
			if(a>0){
				x=(9-v*v)/(2*a);
				dd=d+x;
				l=sreach(1,m,d);
				if(dd==p[l].pp)l++;
				if((dd<p[l].pp)||(d<p[l].pp&&dd>=p[l].pp)){
					p[l].vis=1;
					cnt++;
				}
			}
			else if(a<0){
				x=(9-v*v)/(2*a);
				dd=d+x;
				l=sreach(1,m,d);
				if(dd>p[l].pp&&d<p[l].pp){
					p[l].vis=1;
					cnt++;
				}
			}
		}
		for(int j=1;j<=m;j++){
			if(p[j].vis!=1)cnt1++;
		}
		printf("%d %d\n",cnt,cnt1);
	}
	return 0;
}
